package com.connection.second.wallpaper.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.hutool.core.util.ObjectUtil;
import com.connection.second.common.annotation.Anonymous;
import com.connection.second.wallpaper.domain.vo.PaperAlbumVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.connection.second.common.annotation.Log;
import com.connection.second.common.core.controller.BaseController;
import com.connection.second.common.core.domain.AjaxResult;
import com.connection.second.common.enums.BusinessType;
import com.connection.second.wallpaper.domain.entity.PaperAlbum;
import com.connection.second.wallpaper.service.IPaperAlbumService;
import com.connection.second.common.utils.poi.ExcelUtil;
import com.connection.second.common.core.page.TableDataInfo;

/**
 * 专题管理Controller
 * 
 * @author FL
 * @date 2024-11-12
 */
@Api(tags = "专题管理")
@RestController
@RequestMapping("/wallpaper/album")
public class PaperAlbumController extends BaseController
{
    @Autowired
    private IPaperAlbumService paperAlbumService;

    /**
     * 查询专题管理列表
     */
    @ApiOperation("查询专题列表")
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(PaperAlbum paperAlbum)
    {
        startPage();
        List<PaperAlbumVo> list = paperAlbumService.selectPaperAlbumList(paperAlbum);
        return getDataTable(list);
    }


    /**
     * 获取专题管理详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        PaperAlbumVo vo = paperAlbumService.selectPaperAlbumById(Long.valueOf(id));
        if(ObjectUtil.isNull(vo)){
            return AjaxResult.error("专题不存在");
        }
        return success(vo);
    }

    /**
     * 新增专题管理
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:album:add')")
    @Log(title = "专题管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperAlbum paperAlbum)
    {
        return toAjax(paperAlbumService.insertPaperAlbum(paperAlbum));
    }

    /**
     * 修改专题管理
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:album:edit')")
    @Log(title = "专题管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperAlbum paperAlbum)
    {
        return toAjax(paperAlbumService.updatePaperAlbum(paperAlbum));
    }

    /**
     * 删除专题管理
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:album:remove')")
    @Log(title = "专题管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paperAlbumService.deletePaperAlbumByIds(ids));
    }
}
